(function() {
    angular.module('BlurAdmin.pages.UserlistM')
        .controller('SharingTimesCtrl', SharingTimesCtrl);

    function SharingTimesCtrl($scope, tongxin, $http, $myconfig, $datepicker) {
        var user_id = tongxin.getUserInfo();
        console.log(user_id);
        $scope.dat = {
            dat1: $datepicker.dataNew(),
            dat2: $datepicker.dataNew(),
        };
        $scope.dat.dat1.date_ = '';
        $scope.dat.dat2.date_ = '';

        $scope.search_opt = {
            "limit": 10,
            "page": 1,
            "user_id": user_id,
            "start_time": "",
            "end_time": "",
            'shareapp': ''
        };

        var opt = {};
        //分页
        // $scope.bigTotalItems = 50;
        $scope.pageChanged = function(val) {
            var Page_num = val //选中的页面数
            $scope.search_opt.page = val;
            Search_list();
        };
        $scope.Search = function() { //点击搜索
            var data1 = document.getElementById("dat11") ? document.getElementById("dat11").value : null;
            var data2 = document.getElementById("dat12") ? document.getElementById("dat12").value : null;
            opt = $scope.search_opt;
            opt.start_time = data1;
            opt.end_time = data2;
            $http.get($myconfig.api.users_users_sharelogs_count_b, { params: opt }).then(function(res) {
                $scope.bigTotalItems = res.data.data;
                Search_list();
            })
        }

        function Search_list() { //获取用户数据
            $http.get($myconfig.api.users_users_sharelogs_list_b, { params: opt }).then(function(res) {
                if (res.data.success) {
                    for (var i = 0; i < res.data.data.length; i++) { //添加条数属性
                        res.data.data[i].index = (($scope.search_opt.page - 1) * $scope.search_opt.limit) + i + 1;
                    }
                    $scope.list_data = res.data.data;
                }
                console.log($scope.list_data);
            })
        }
        $scope.Search();



    }

})();